# -*- coding: utf-8 -*-
'''
Created on 2014/01/03

@author: deadblue
'''
import jinja2
import os

template_ext = 'html'

jinja2_env = jinja2.Environment(autoescape=True, extensions=['jinja2.ext.autoescape'],
    loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'template')))

def render(name, data):
    tpl_name = "%s.%s" % (name, template_ext)
    tpl = jinja2_env.get_template(tpl_name)
    return tpl.render(data)

def render_response(response, name, data):
    response.headers['Content-Type'] = 'text/html'
    response.write(render(name, data))
    pass